package com.lysj.admin.master.common.spring.mpbase.condition;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.function.BiConsumer;

/**
 * @author Created by zk on 2019-12-24 20:41
 * @description
 */
@Getter
@AllArgsConstructor
@SuppressWarnings("unchecked")
public enum MpPredicateEnum {
    //equal
    EQ((wrapper, dto) -> wrapper.eq(dto.getProperty(),dto.getVal())),
    //not equal
    NE((wrapper, dto) -> wrapper.ne(dto.getProperty(),dto.getVal())),
    //grater than
    GT((wrapper, dto) -> wrapper.gt(dto.getProperty(),dto.getVal())),
    //grater than equal
    GE((wrapper, dto) -> wrapper.ge(dto.getProperty(),dto.getVal())),
    //less than
    LT((wrapper, dto) -> wrapper.lt(dto.getProperty(),dto.getVal())),
    //less than equal
    LE((wrapper, dto) -> wrapper.le(dto.getProperty(),dto.getVal())),
    //full like %XX%
    F_LK((wrapper, dto) -> wrapper.like(dto.getProperty(),dto.getVal())),
    //left like %XX
    L_LK((wrapper, dto) -> wrapper.likeLeft(dto.getProperty(),dto.getVal())),
    //right like XX%
    R_LK((wrapper, dto) -> wrapper.likeRight(dto.getProperty(),dto.getVal())),
    //in
    IN((wrapper, dto) -> wrapper.in(dto.getProperty(),dto.getVal())),
    //not in
    NI((wrapper, dto) -> wrapper.notIn(dto.getProperty(),dto.getVal()))
    ;
    private BiConsumer<QueryWrapper,MpPredicateDTO> predicateFunc;
}
